package com.chunuo.commonbase;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * 类的作用
 *
 * @author liujiamiao
 * @email 2544296058@qq.com
 * @date 2020-07-04 11:36
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket webApiConfig(){
        return new Docket(DocumentationType.SWAGGER_2)
                //名称
                .groupName("webApi")
                .apiInfo(webApiInfo())
                .select()
                //屏蔽的接口，不产生接口文档
//                .paths(Predicates.not(PathSelectors.regex("/admin/.*")))
                .paths(Predicates.not(PathSelectors.regex("/error.*")))
                .build();

    }

    private ApiInfo webApiInfo(){

        return new ApiInfoBuilder()
                //标题
                .title("网站-课程中心API文档")
                //介绍内容
                .description("本文档描述了课程中心微服务接口定义")
                //版本
                .version("1.0")
                //相关联系信息
                .contact(new Contact("java", "http://chunuo.com", "2544296058@qq.com"))
                .build();
    }

}
